Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hurricup/fixes #2952

Merged
merged 4 commits into from
Dec 15, 2024
Merged

Hurricup/fixes #2952

merged 4 commits into from
Dec 15, 2024

Conversation

hurricup
Copy link
Collaborator

@hurricup hurricup commented Dec 15, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced syntax highlighting for various Perl constructs.
    • Added new test cases for regex patterns in Perl.
    • Introduced a new configuration file for syntax highlighting.
  • Bug Fixes

    • Improved conditions for executing SonarCube analysis.
  • Tests

    • Added a new test method for Perl parser functionality.
  • Chores

    • Updated copyright notice to reflect the year 2024.

@hurricup hurricup enabled auto-merge (rebase) December 15, 2024 14:41
Copy link

coderabbitai bot commented Dec 15, 2024

Walkthrough

This pull request encompasses modifications across multiple files in the Perl plugin, focusing on workflow configuration, lexer updates, module extension refinement, project generator peer modifications, and test resource additions. The changes primarily involve enhancing syntax handling, updating component initialization logic, and expanding test coverage for Perl language parsing and regex interpolation scenarios.

Changes

File Change Summary
.github/workflows/_coverage.yml Updated SonarCube analysis conditions to require both COVERALLS_REPO_TOKEN and SONAR_TOKEN
plugin/core/grammar/Perl.flex Modified regex patterns for REGEX_ARRAY_NEGATING and REGEX_HASH_NEGATING by adding characters
plugin/core/src/main/java/com/intellij/openapi/projectRoots/impl/PerlModuleExtension.java Removed myDisposalTrace variable and assertNotDisposed() method, simplified disposal logic
plugin/core/src/main/java/com/perl5/lang/perl/idea/configuration/module/PerlProjectGeneratorPeer.java Updated constructor to pass a JPanel with VerticalFlowLayout to superclass
plugin/core/src/main/java/com/perl5/lang/perl/idea/configuration/module/PerlProjectGeneratorPeerBase.java Refactored constructor and component management, added new method signatures
plugin/src/test/java/unit/perl/parser/PerlParserLikeTest.java Added new test method testIndexesAsRegexInterpolated()
plugin/src/test/resources/highlighting/perl/syntax/indexesAsRegexInterpolated.pl.txt Added new syntax highlighting definitions for Perl constructs
plugin/src/test/resources/unit/perl/parser/indexesAsRegexInterpolated.code Added new test cases for regex patterns and interpolations
plugin/src/test/resources/unit/perl/parser/indexesAsRegexInterpolated.txt Added new file representing Perl syntax parsing structure

Possibly related issues

Poem

🐰 In the realm of Perl's syntax dance,
Regex patterns take a playful stance,
Extensions trimmed, tests expand with glee,
Code flows smoother, more efficiently,
A rabbit's leap through language's expanse! 🧩

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. This feature will be included in our Pro Plan when released.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
plugin/src/test/resources/unit/perl/parser/indexesAsRegexInterpolated.code (1)

10-17: Consider adding edge cases for more thorough testing.

While the current test cases are good, consider adding:

  • Tests with nested array/hash access
  • Tests with complex expressions in brackets
  • Tests with special regex characters in the keys

Example additions:

$test[/$other[1]/];
$hash{/foo\/bar/};
$array[$x + 1];
plugin/core/src/main/java/com/perl5/lang/perl/idea/configuration/module/PerlProjectGeneratorPeerBase.java (1)

43-47: Consider adding @OverRide annotation.

The method overloads the parent's method but missing the @OverRide annotation.

+  @Override
   public @NotNull JComponent getComponent(@NotNull TextFieldWithBrowseButton myLocationField, @NotNull Runnable checkValid) {
plugin/src/test/resources/highlighting/perl/syntax/indexesAsRegexInterpolated.pl.txt (1)

45-64: Consider adding edge cases for regex patterns.

While the basic regex interpolation is covered, consider adding test cases for:

  • Complex regex patterns with metacharacters
  • Nested brackets in regex patterns
plugin/core/grammar/Perl.flex (2)

148-148: LGTM! Consider adding documentation

The addition of '/' to REGEX_ARRAY_NEGATING is correct for handling array interpolation in regex patterns. Consider adding a comment explaining the role of each character in the pattern for future maintenance.

Add a comment like:

+ // Characters that negate array interpolation in regex context:
+ // ^ (caret), : (colon), \ (backslash), [ (left bracket), { (left brace),
+ // . (dot), , (comma), ' (single quote), " (double quote), } (right brace),
+ // ) (right paren), / (forward slash)
 REGEX_ARRAY_NEGATING = [\^\:\\\[\{\.\,\'\"})/]

149-149: LGTM! Consider adding documentation

The addition of '/' to REGEX_HASH_NEGATING is correct for handling hash interpolation in regex patterns. Consider adding a comment explaining the role of each character in the pattern for future maintenance.

Add a comment like:

+ // Characters that negate hash interpolation in regex context:
+ // ^ (caret), : (colon), \ (backslash), [ (left bracket), { (left brace),
+ // . (dot), , (comma), / (forward slash)
 REGEX_HASH_NEGATING = [\^\:\\\[\{\.\,/]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f651fd and f676e29.

⛔ Files ignored due to path filters (1)
  • plugin/core/src/main/gen/com/perl5/lang/perl/lexer/PerlLexer.java is excluded by !**/gen/**
📒 Files selected for processing (9)
  • .github/workflows/_coverage.yml (1 hunks)
  • plugin/core/grammar/Perl.flex (1 hunks)
  • plugin/core/src/main/java/com/intellij/openapi/projectRoots/impl/PerlModuleExtension.java (0 hunks)
  • plugin/core/src/main/java/com/perl5/lang/perl/idea/configuration/module/PerlProjectGeneratorPeer.java (2 hunks)
  • plugin/core/src/main/java/com/perl5/lang/perl/idea/configuration/module/PerlProjectGeneratorPeerBase.java (4 hunks)
  • plugin/src/test/java/unit/perl/parser/PerlParserLikeTest.java (1 hunks)
  • plugin/src/test/resources/highlighting/perl/syntax/indexesAsRegexInterpolated.pl.txt (1 hunks)
  • plugin/src/test/resources/unit/perl/parser/indexesAsRegexInterpolated.code (1 hunks)
  • plugin/src/test/resources/unit/perl/parser/indexesAsRegexInterpolated.txt (1 hunks)
💤 Files with no reviewable changes (1)
  • plugin/core/src/main/java/com/intellij/openapi/projectRoots/impl/PerlModuleExtension.java
🔇 Additional comments (13)
plugin/src/test/resources/unit/perl/parser/indexesAsRegexInterpolated.code (1)

1-8: LGTM! Comprehensive test coverage for array access in regex contexts.

The test cases effectively cover array access within different regex contexts including direct access, string interpolation, and various Perl operators.

plugin/core/src/main/java/com/perl5/lang/perl/idea/configuration/module/PerlProjectGeneratorPeer.java (1)

19-25: LGTM! Clean implementation of UI layout changes.

The addition of VerticalFlowLayout is appropriate for form-based UI components. The constructor change properly integrates with the superclass modifications.

Let's verify other potential layout usages:

✅ Verification successful

VerticalFlowLayout usage is consistent across the codebase

The verification shows that VerticalFlowLayout is consistently used across multiple UI components in the codebase, including configuration panels, settings editors, and debugger interfaces. The implementation in PerlProjectGeneratorPeer follows the same pattern as other similar components, particularly in configuration-related classes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other VerticalFlowLayout usages to ensure consistency
rg "VerticalFlowLayout" --type java

Length of output: 3050

.github/workflows/_coverage.yml (1)

63-63: LGTM! Enhanced security check for SonarCube analysis.

The additional token validation ensures that the SonarCube analysis only runs when all required credentials are present, preventing incomplete or failed analysis attempts.

plugin/core/src/main/java/com/perl5/lang/perl/idea/configuration/module/PerlProjectGeneratorPeerBase.java (4)

31-34: LGTM: Field declaration and initialization look good.

The new field myMainComponent is properly declared as final and annotated with @NotNull.


36-40: LGTM: Constructor implementation is correct.

The constructor properly:

  • Accepts and validates the mainComponent parameter
  • Calls super constructor
  • Initializes fields

67-69: LGTM: Component creation is simplified.

The method now directly returns myMainComponent, which is cleaner than the previous implementation.


60-63: Verify the component initialization order.

The method now adds components to myMainComponent directly. Ensure this doesn't affect the initialization order of UI components.

✅ Verification successful

Based on the search results, I can now provide a final response:

The component initialization order is correctly maintained

The code follows a proper initialization pattern where:

  • myMainComponent is initialized in the constructor
  • initializeComponent() is lazily called via myComponentProvider
  • The component hierarchy is maintained with mySdkConfigurable being added as a child component
  • The final component is exposed through createComponent() which returns the fully initialized myMainComponent
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of initializeComponent to verify initialization order
ast-grep --pattern 'class $_ {
  $$$
  initializeComponent($$$) {
    $$$
  }
  $$$
}'

Length of output: 88


Script:

#!/bin/bash
# Let's try a different approach to find usages of initializeComponent and myMainComponent
rg -A 5 "initializeComponent|myMainComponent" --type java

# Also search for the base class or interface that might define this method
rg -B 2 "class PerlProjectGeneratorPeerBase" --type java

Length of output: 4540

plugin/src/test/resources/highlighting/perl/syntax/indexesAsRegexInterpolated.pl.txt (1)

1-16: LGTM: Array element regex interpolation test cases are comprehensive.

The test cases properly cover:

  • Basic array element access with regex
  • Proper token highlighting for regex delimiters
  • Proper token highlighting for array syntax
plugin/src/test/resources/unit/perl/parser/indexesAsRegexInterpolated.txt (3)

1-100: LGTM: AST structure for array element regex interpolation is well-defined.

The parser test correctly defines:

  • PsiPerlArrayElementImpl structure
  • PsiPerlMatchRegexImpl structure
  • Proper nesting of elements

101-199: LGTM: AST structure for hash element regex interpolation is comprehensive.

The test cases properly cover:

  • Hash element access with regex
  • String interpolation within hash context
  • Various regex operations in hash context

200-203: LGTM: POD documentation is properly structured.

The POD section correctly documents all test cases with their expected syntax.

plugin/src/test/java/unit/perl/parser/PerlParserLikeTest.java (1)

29-30: Verify test resources for regex interpolation test

The test method follows the class's pattern, but ensure the corresponding test resources exist:

  • plugin/src/test/resources/unit/perl/parser/indexesAsRegexInterpolated.code
  • plugin/src/test/resources/unit/perl/parser/indexesAsRegexInterpolated.txt
✅ Verification successful

Test resources are properly set up

The required test resource files are present in the expected location:

  • plugin/src/test/resources/unit/perl/parser/indexesAsRegexInterpolated.code
  • plugin/src/test/resources/unit/perl/parser/indexesAsRegexInterpolated.txt
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the required test resources exist

# Check for test resource files
fd -t f "indexesAsRegexInterpolated" plugin/src/test/resources/unit/perl/parser/

Length of output: 229

plugin/core/grammar/Perl.flex (1)

148-149: Verify fix addresses referenced issues

The changes to both regex negation patterns look correct and are well-tested. Please ensure these changes address the issues mentioned in the PR description (#2946, #2948, #2915).

✅ Verification successful

Let me analyze the issue context and verify the changes. Looking at the issues:

  1. Issue The parser does not understand the delimiter curly bracket in a regular expression. #2948 is directly relevant to our changes as it describes a bug where the parser doesn't correctly handle delimiter curly brackets in regular expressions, specifically with a slash character inside character classes.

Let me verify if there are any related test cases for this fix.


Let me check for test files specifically related to the lexer and regex parsing.


Let me check the parser test files for regex-related test cases.


Based on the analysis of the code and test files, I can now provide a final response:

Changes correctly address regex delimiter handling

The modifications to REGEX_ARRAY_NEGATING and REGEX_HASH_NEGATING patterns are verified to be correct. The changes:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the referenced issues for context

# Fetch issue details
gh issue view 2946
gh issue view 2948
gh issue view 2915

Length of output: 14328


Script:

#!/bin/bash
# Check for related test files and test cases
rg -l "s\{.*\[.*\].*\}" --type perl
rg -l "regex.*negat" --type perl

Length of output: 988


Script:

#!/bin/bash
# Look for test files related to regex parsing
fd -e "t" -e "test" | rg -i "regex|lexer"

# Check for recent changes in test files
fd "test" | xargs rg -l "\[\^.*\]" 

Length of output: 15360


Script:

#!/bin/bash
# Check parser test files for regex-related tests
cat plugin/src/test/resources/unit/perl/parser/charGroups.code plugin/src/test/resources/unit/perl/parser/charGroups.txt

# Check for recent changes in regex-related test files
cat plugin/src/test/resources/unit/perl/parser/superExtendedRegexp.code plugin/src/test/resources/unit/perl/parser/superExtendedRegexp.txt

Length of output: 16829

Copy link

Qodana for JVM

1437 new problems were found

Inspection name Severity Problems
Usage of API marked for removal 🔴 Failure 4
Unused declaration 🔶 Warning 1158
Method always returns the same value 🔶 Warning 163
Declaration can have 'final' modifier 🔶 Warning 37
Null-check method is called with obviously non-null argument 🔶 Warning 13
Raw use of parameterized class 🔶 Warning 12
Empty method 🔶 Warning 9
Redundant 'throws' clause 🔶 Warning 6
Deprecated API usage 🔶 Warning 5
Redundant semicolon 🔶 Warning 4
Field may be 'final' 🔶 Warning 2
Hardcoded strings 🔶 Warning 2
A service can be converted to a light one 🔶 Warning 2
Redundant qualifier name 🔶 Warning 2
Unnecessary boxing 🔶 Warning 2
Unused import directive 🔶 Warning 1
@NotNull/@Nullable problems 🔶 Warning 1
Redundant 'Collection' operation 🔶 Warning 1
Redundant usage of unmodifiable collection wrappers 🔶 Warning 1
Method can be made 'void' 🔶 Warning 1
Unused symbol 🔶 Warning 1
Plugin Logo check ◽️ Notice 6
Class member can have 'private' visibility ◽️ Notice 3
Non-canonical modifier order ◽️ Notice 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Detected 11 dependencies

Third-party software list

This page lists the third-party software dependencies used in perl5

Dependency Version Licenses
ant-launcher 1.10.13 Apache-2.0
W3C-19980720
ant 1.10.13 Apache-2.0
W3C-19980720
com.jetbrains.performanceplugin ic-243.21565.193 Apache-2.0
com.jetbrains.performanceplugin iu-243.21565.193 Apache-2.0
docker iu-243.21565.193 Apache-2.0
jflex 1.9.2 BSD-3-Clause
jsr305 3.0.2 Apache-2.0
tanvd.grazi ic-243.21565.193 Apache-2.0
LGPL-2.0-or-later
LGPL-2.1-only
MIT
tanvd.grazi iu-243.21565.193 Apache-2.0
LGPL-2.0-or-later
LGPL-2.1-only
MIT
testng-j ic-243.21565.193 MIT
testng-j iu-243.21565.193 MIT
Contact Qodana team

Contact us at [email protected]

@hurricup hurricup merged commit 017cf50 into master Dec 15, 2024
36 of 37 checks passed
@hurricup hurricup deleted the hurricup/fixes branch December 15, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant